#include <fstream>
#include <vector>
#include <string>
#include <set>

using namespace std;

set<string>	DirSet;

int Calc(string path)
{
	if (path.empty())
		return 0;

	if (DirSet.find(path) != DirSet.end())
		return 0;

	DirSet.insert(path);

	int splash = path.find_last_of('/');
	string parentPath = path.substr(0, splash);

	return Calc(parentPath)+1;
}

void RunA(const char* fnameIn, const char* fnameOut)
{
	ifstream fin(fnameIn);
	
	int caseCount;
	fin >> caseCount;

	ofstream fout(fnameOut);

	int N, M;
	string s;

	for (int i=0; i<caseCount; i++)
	{
		DirSet.clear();
		DirSet.insert("/");

		fin>>N>>M;

		for (int n=0; n<N; n++)
		{
			fin>>s;
			Calc(s);
		}

		int r =0;
		for (int n=0; n<M; n++)
		{
			fin>>s;
			r += Calc(s);
		}

		fout<<"Case #"<<i+1<<": ";
		fout<< r;
		fout<<"\n";
	}
}

//int main(int argc, int argv[])
//{
//	RunA("A-small-practice.in", "A-small-practice.out");
//	RunA("A-large-practice.in", "A-large-practice.out");
//
//	return 0;
//}


